#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 5e4 + 5;

int n, m;

struct Node {
  int lmx, rmx, mx, sum, tag;
} tr[N << 2];
Node merge(Node x, Node y) {
  Node res;
  res.lmx = x.lmx == x.sum ? x.sum + y.lmx : x.lmx;
  res.rmx = y.rmx == y.sum ? y.sum + x.rmx : y.rmx;
  res.mx = max({x.mx, y.mx, x.rmx + y.lmx});
  res.sum = x.sum + y.sum;
  res.tag = -1;
  return res;
}
void build(int p, int l, int r) {
  if (l == r) {
    tr[p] = {1, 1, 1, 1, -1};
    return;
  }
  int mid = (l + r) >> 1;
  build(p << 1, l, mid);
  build(p << 1 | 1, mid + 1, r);
  tr[p] = merge(tr[p << 1], tr[p << 1 | 1]);
}
void addtag(int d, int p) {
  tr[p].lmx = tr[p].rmx = tr[p].mx = d * tr[p].sum;
  tr[p].tag = d;
}
void pushdown(int p) {
  if (tr[p].tag != -1) {
    addtag(tr[p].tag, p << 1);
    addtag(tr[p].tag, p << 1 | 1);
    tr[p].tag = -1;
  }
}
void update(int L, int R, int d, int p, int l, int r) {
  if (L <= l && R >= r) {
    addtag(d, p);
    return;
  }
  pushdown(p);
  int mid = (l + r) >> 1;
  if (L <= mid) update(L, R, d, p << 1, l, mid);
  if (R > mid) update(L, R, d, p << 1 | 1, mid + 1, r);
  tr[p] = merge(tr[p << 1], tr[p << 1 | 1]);
}
Node query(int L, int R, int p, int l, int r) {
  if (L <= l && R >= r) return tr[p];
  pushdown(p);
  int mid = (l + r) >> 1;
  if (L <= mid && R > mid) {
    Node x = query(L, R, p << 1, l, mid);
    Node y = query(L, R, p << 1 | 1, mid + 1, r);
    return merge(x, y);
  } else if (L <= mid)
    return query(L, R, p << 1, l, mid);
  else
    return query(L, R, p << 1 | 1, mid + 1, r);
}
void done(int x) {
  if (x > n) {
    cout << 0 << endl;
    return;
  }
  int l = x, r = n;
  while (l <= r) {
    int mid = (l + r) >> 1;
    Node res = query(1, mid, 1, 1, n);
    if (res.mx < x)
      l = mid + 1;
    else
      r = mid - 1;
  }
  r = l, l = r + 1 - x;
  if (r > n) {
    cout << 0 << endl;
    return;
  }
  cout << l << endl;
  update(l, r, 0, 1, 1, n);
}
void undo(int x, int y) { update(x, y, 1, 1, 1, n); }
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  build(1, 1, n);
  while (m--) {
    int op, x, y;
    cin >> op >> x;
    if (op == 1)
      done(x);
    else {
      cin >> y;
      undo(x, x + y - 1);
    }
  }
  return 0;
}